# Maintainer: Zhang Hai <dreaming.in.code.zh@gmail.com>
# Contributor: Felix Golatofski <contact@xdfr.de>
# Contributor: Vlad M. <vlad@archlinux.net>
# Contributor: Gordin <9ordin @t gmail dot com>
# Contributor: Christoph Bayer <chrbayer@criby.de>

pkgname=android-sdk-platform-tools
pkgver=r36.0.0
pkgrel=1
pkgdesc='Platform-Tools for Google Android SDK (adb and fastboot)'
arch=('x86_64')
url='https://developer.android.com/sdk/index.html'
license=('custom')
depends=('zlib' 'ncurses')
provides=('adb' 'android-tools')
conflicts=('adb')
replaces=('android-tools')
options=('!debug')
install="$pkgname.install"
source=("https://dl.google.com/android/repository/platform-tools_$pkgver-linux.zip"
        'adb.service'
        'license.html')
sha512sums=('de2c00a5797ca29014a89f7ed6e21fffc65dd06ea1ffc3d9c2563119c0b6084492e16018564a07d71a6a11e1ca413c021f7a1825ab3d390a967b8c12f69a9062'
            'faf315d2bb7a9caa099db32e21451a1fd8fcc76475f25b36742356adc4f758e6fc7512106f9539b2db687c9566ef5889a4fa051c3c1a84555090d4b175e485d4'
            '23f1533682c39e2ae2ae40083de343abcd6ed0a523eacdac58768067f8f450b1cec30073993dd7b972a5b8125136ed29a043ae894dff046fd75bb04c4d21a0f4')

package() {
  install -dm 755 "$pkgdir/etc/profile.d"
  install -dm 755 "$pkgdir/opt/android-sdk/"

  install -Dm 644 "$srcdir/adb.service" "$pkgdir/usr/lib/systemd/system/adb.service"
  install -Dm 644 "$srcdir/license.html" "$pkgdir/usr/share/licenses/$pkgname/license.html"

  echo 'export PATH="$PATH:/opt/android-sdk/platform-tools"' >"$pkgdir/etc/profile.d/$pkgname.sh"
  echo 'setenv PATH "$PATH:/opt/android-sdk/platform-tools"' >"$pkgdir/etc/profile.d/$pkgname.csh"
  chmod 755 "$pkgdir/etc/profile.d/$pkgname"{.csh,.sh}
  cp -a "$srcdir/platform-tools" "$pkgdir/opt/android-sdk/platform-tools"
  chmod -R +rX "$pkgdir/opt/android-sdk/platform-tools"
}

